package com.wanlian.fileserver.controller;


import com.wanlian.fileserver.controller.vo.FileDeleteVo;
import com.wanlian.fileserver.controller.vo.FileRenameVo;
import com.wanlian.fileserver.device.worker.DeviceServerFileWorker;
import com.wanlian.json.JsonStringUtil;
import com.wanlian.netty.File.msg.util.FileDeleteMsg;
import com.wanlian.netty.File.msg.util.FileRenameMsg;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
@RequestMapping("/file")
@EnableAutoConfiguration
public class FileController {

    @RequestMapping("/rename")
    public String reanme(@RequestBody  String data){
        FileRenameVo vo=JsonStringUtil.readValue(data, FileRenameVo.class);
        FileRenameMsg renameMsg=new FileRenameMsg(data);
        DeviceServerFileWorker.sendDataByKey("",renameMsg);
        return "";
    }
    @RequestMapping("/delete")
    public String delete(@RequestBody String data){
        FileDeleteVo vo=JsonStringUtil.readValue(data, FileDeleteVo.class);
        FileDeleteMsg deleteMsg=new FileDeleteMsg(data);
        DeviceServerFileWorker.sendDataByKey("",deleteMsg);
        return "";
    }

}
